package ticketmachine.logic;

import ticketmachine.dataObjects.DAOFactory;

public class Station {

	private int id;
	public String name;
	public String address;
	private int previousStation;
	private int nextStation;
	
	public Station(int id, String name, String address, int previousStation, int nextStation) {
		
		this.id = id;
		this.name = name;
		this.address = address;
		this.previousStation = previousStation;
		this.nextStation = nextStation;
	}
	
	public Station(){
		
	}
	
	public static int calculateDistance(Station source, Station destination){
		int distanceOne=Math.abs(source.getId()-destination.getId());
		int numStations=DAOFactory.getInstance().getStationDAO().listStations().size();
		int distanceTwo=numStations-distanceOne+1;
		if (distanceTwo < distanceOne){
			return distanceTwo;
		}else{
			return distanceOne;
		}
		
	}
	
	
	// Getters and Setters
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getPreviousStation() {
		return previousStation;
	}

	public void setPreviousStation(int previousStation) {
		this.previousStation = previousStation;
	}

	public int getNextStation() {
		return nextStation;
	}

	public void setNextStation(int nextStation) {
		this.nextStation = nextStation;
	}
	
	
}
